﻿using TEngine;
using UnityEngine;

namespace GameLogic
{
    partial class OnlineLobbyUI
    {
        #region 流程回调
        protected override void OnRefresh()
        {
            base.OnRefresh();
            m_tmpTextLocalIP.text = GlobalFunction.GetLocalIP();
            m_btnStartGame.gameObject.SetActive(false);
        }
        protected override void RegisterEvent()
        {
            base.RegisterEvent();
            m_btnCreateGame.onClick.AddListener(OnClickCreateBtn);
            m_btnJoinGame.onClick.AddListener(OnClickJoinGameBtn);
            m_btnStartGame.onClick.AddListener(OnStartGameClicked);
            m_btnSwitchShip.onClick.AddListener(OnSwitchShipClicked);
            m_btnExBack.AddClickEvent(() =>
            {
                GameEvent.Send(GameEventType.OnBackClicked);
            });
            AddUIEvent(GameEventType.OnJointedLobby, () => {
            });
        }
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (Input.GetKeyDown(KeyCode.S))
            {
            }
            if (Input.GetKeyDown(KeyCode.C))
            {
            }
        }
        #endregion

        #region UI回调
        void OnClickJoinGameBtn()
        {
            FightLogicManager.Instance.CreateClient(GlobalFunction.ClientType.Client, m_tmpInputIPInputer.text);
            m_btnStartGame.gameObject.SetActive(false);
        }
        void OnClickCreateBtn()
        {
            FightLogicManager.Instance.CreateClient(GlobalFunction.ClientType.Server);
            m_btnStartGame.gameObject.SetActive(true);
        }
        void OnStartGameClicked()
        {
            GameEvent.Send(GameEventType.OnOnlineGameStartClicked);
        }
        void OnSwitchShipClicked()
        {
            GameModule.UI.ShowUI<ShipConfigUI>(true);
        }
        #endregion
    }
}